/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.app.examinate.extheory.user.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jeesite.common.config.Global;
import com.jeesite.common.entity.Page;
import com.jeesite.common.web.BaseController;
import com.jeesite.modules.app.examinate.extheory.user.entity.AppUserExtheory;
import com.jeesite.modules.app.examinate.extheory.user.service.AppUserExtheoryService;

/**
 * 用户理论考试记录表Controller
 * @author zpp
 * @version 2020-02-08
 */
@Controller
@RequestMapping(value = "${adminPath}/app/examinate/extheory/user/appUserExtheory")
public class AppUserExtheoryController extends BaseController {

	@Autowired
	private AppUserExtheoryService appUserExtheoryService;
	
	/**
	 * 获取数据
	 */
	@ModelAttribute
	public AppUserExtheory get(String id, boolean isNewRecord) {
		return appUserExtheoryService.get(id, isNewRecord);
	}
	
	/**
	 * 查询列表
	 */
	@RequiresPermissions("app:examinate:extheory:user:appUserExtheory:view")
	@RequestMapping(value = {"list", ""})
	public String list(AppUserExtheory appUserExtheory, Model model) {
		model.addAttribute("appUserExtheory", appUserExtheory);
		return "modules/app/examinate/extheory/user/appUserExtheoryList";
	}
	
	/**
	 * 查询列表数据
	 */
	@RequiresPermissions("app:examinate:extheory:user:appUserExtheory:view")
	@RequestMapping(value = "listData")
	@ResponseBody
	public Page<AppUserExtheory> listData(AppUserExtheory appUserExtheory, HttpServletRequest request, HttpServletResponse response) {
		appUserExtheory.setPage(new Page<>(request, response));
		Page<AppUserExtheory> page = appUserExtheoryService.findPage(appUserExtheory);
		return page;
	}

	/**
	 * 查看编辑表单
	 */
	@RequiresPermissions("app:examinate:extheory:user:appUserExtheory:view")
	@RequestMapping(value = "form")
	public String form(AppUserExtheory appUserExtheory, Model model) {
		model.addAttribute("appUserExtheory", appUserExtheory);
		return "modules/app/examinate/extheory/user/appUserExtheoryForm";
	}

	/**
	 * 保存用户理论考试记录表
	 */
	@RequiresPermissions("app:examinate:extheory:user:appUserExtheory:edit")
	@PostMapping(value = "save")
	@ResponseBody
	public String save(@Validated AppUserExtheory appUserExtheory) {
		appUserExtheoryService.save(appUserExtheory);
		return renderResult(Global.TRUE, text("保存用户理论考试记录表成功！"));
	}
	
	/**
	 * 删除用户理论考试记录表
	 */
	@RequiresPermissions("app:examinate:extheory:user:appUserExtheory:edit")
	@RequestMapping(value = "delete")
	@ResponseBody
	public String delete(AppUserExtheory appUserExtheory) {
		appUserExtheoryService.delete(appUserExtheory);
		return renderResult(Global.TRUE, text("删除用户理论考试记录表成功！"));
	}
	
}